package com.bicycle.rentalsystem.dao.impl.user;

import com.bicycle.rentalsystem.dao.user.UserMessageDao;
import com.bicycle.rentalsystem.handler.MultiResultHandler;
import com.bicycle.rentalsystem.handler.SingleResultHandler;
import com.bicycle.rentalsystem.jdbc.JdbcUtil;
import com.bicycle.rentalsystem.pojo.user.UserMessage;

import java.util.List;


public class UserMessageDaoImpl implements UserMessageDao {

    @Override
    public UserMessage getMessage(String username) {
        String sql = "SELECT * FROM `user` WHERE username=?" ;
        return JdbcUtil.query(sql,new SingleResultHandler<>(UserMessage.class),username);
    }

    @Override
    public int returnMessage(String username) {
        String sql="update user set `sex`=? ,`qianming`=? ,`telephone`=? where username=?";
        return JdbcUtil.update(sql,username);
    }

    @Override
    public int returnPassword(String password) {
        String sql="update user set `username`=?,`password`=? where password=?";
        return JdbcUtil.update(sql,password);
    }
}
